$(document).ready(function() {

	if($('.box_skitter_large')[0]) {
		$('.box_skitter_large').skitter({
			enable_navigation_keys: false,
			focus: false,
			label: false,
			stop_over: true,
			interval: 3000
		});
		$(".prev_button").remove();
		$(".next_button").remove();
		$(".info_slide").css("left", "0");
	}

	//产品分类轮播图
	new Swiper('.product-banner', {
		slidesPerView: 4,
		slidesPerGroup: 1,
		nextButton: '.swiper-button-next',
		prevButton: '.swiper-button-prev',
	})

	//产品轮播鼠标移入移出的动画
	$('.swiper-slide').mouseenter(function() {
		$(this).find('.product-blue-model').addClass('layui-anim-scale').show();
	})
	$('.swiper-slide').mouseleave(function() {
		$(this).find('.product-blue-model').removeClass('layui-anim-scale').hide();
	})

	//工程案例轮播图
	new Swiper('.case-center-banner', {
		pagination: '.case-center-change-btn',
		width : 1100,
		height: 100,
		slidesPerView: 5,
		slidesPerColumn: 2,
//		setWrapperSize :true,
		paginationClickable: true,
		spaceBetween: 18
	})

	//工程案例轮播图
	var myZturn = new zturn({
		id: "workShopBanner",
		opacity: 1,
		width: 382,
		Awidth: 1101,
		scale: 0.9
	})
	changeStyle()

	function changeStyle() {
		$('.poster-item').each(function(index, element) {
			if(element.style.zIndex == 5) {
				$(element).addClass('workShopAnimation').siblings().removeClass('workShopAnimation')
			}
		})
	}
	$('.prevClick').click(function() {
		myZturn.prev_()
		changeStyle()
	})
	$('.nextClick').click(function() {
		myZturn.next_()
		changeStyle()
	})

	//新闻中心轮播图
	new Swiper('.news-center-banner', {
		pagination: '.news-center-change-btn',
		paginationClickable: true,
		width: 405
	})
	//新闻中心文字详情超出部分文字隐藏，显示省略号
	$('.ellipsis-details').ellipsis({
		english: false,
		lineNum: 2
	});

});

$(window).load(function() {

	// 首页滚动动画
	$(window).scroll(function() {
		if($(".images-list-box-scroll").get(0) && ($(".images-list-box-scroll").offset().top - $(document).scrollTop() <= 600)) {
			showActive($(".images-list-box-scroll .images-list"), 200, 0, "ani-p-li", false);
		}
		if($(".product-category").get(0) && ($(".product-category").offset().top - $(document).scrollTop() <= 600)) {
			showActive($(".product-category .trans01"), 200, 0, "ani-p-li", false);
		}
		if($(".about-us-category").get(0) && ($(".about-us-category").offset().top - $(document).scrollTop() <= 600)) {
			$(".about-us-category .main-title-type").addClass("main-title-animation");
			showActive($(".about-us-category .trans00"), 200, 0, "ani-p-li", false);
		}
		if($(".case-center-category").get(0) && ($(".case-center-category").offset().top - $(document).scrollTop() <= 600)) {
			$(".case-center-category .main-title-type").addClass("main-title-animation");
			showActive($(".case-center-category .trans00"), 300, 0, "ani-p-l", false);
		}
		if($(".work-shop-category").get(0) && ($(".work-shop-category").offset().top - $(document).scrollTop() <= 600)) {
			$(".work-shop-category .main-title-type").addClass("main-title-animation");
			showActive($(".work-shop-category .trans00"), 300, 0, "ani-p-l", false);
		}
		if($(".news-center-category").get(0) && ($(".news-center-category").offset().top - $(document).scrollTop() <= 600)) {
			$(".news .news_swiper").removeClass("ani-p-li");
			showActive($(".news-center-category .trans01"), 300, 0, "ani-p-li", false);
		}
	})
	setTimeout(function() {
		showActive($(".images-list-box .images-list"), 200, 0, "ani-p-li", false);
		showActive($(".pub_cate li"), 300, 0, "ani-p-li", false);
		showActive($(".page-and-change"), 200, 0, "ani-p-li", false);
		showActive($(".i_about p"), 200, 0, "ani-p-li", false);
		showActive($(".i_case .trans00"), 200, 0, "ani-p-l", false);
		showActive($(".i_case_list li"), 200, 0, "ani-p-li", false);
		showActive($(".i_contact .trans00"), 200, 0, "ani-p-li", false);
		showActive($(".i_core .trans02"), 200, 0, "ani-r-pic", false);
		showActive($(".i_core .trans00"), 200, 0, "ani-p-l", false)
	})
})

function showActive(li, t1, t2, rc, p) {
	setTimeout(function() {
		var time = 0;
		var set = setInterval(function() {
			if(p) {
				li.eq(time).addClass(rc);
				time++;
				if(time >= li.length) {
					clearInterval(set);
				}
			} else {
				li.eq(time).removeClass(rc);
				time++;
				if(time >= li.length) {
					clearInterval(set);
				}
			}
		}, t1);
	}, t2);
}